home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / include / config-win.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-28  |  10.0 KB  |  342 lines

  1. /* Copyright (C) 2000 MySQL AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* Defines for Win32 to make it compatible for MySQL */
  18.  
  19. #include <sys/locking.h>
  20. #include <windows.h>
  21. #include <math.h>            /* Because of rint() */
  22. #include <fcntl.h>
  23. #include <io.h>
  24. #include <malloc.h>
  25.  
  26. #if defined(__NT__)
  27. #define SYSTEM_TYPE    "NT"
  28. #elif defined(__WIN2000__)
  29. #define SYSTEM_TYPE    "WIN2000"
  30. #else
  31. #define SYSTEM_TYPE    "Win95/Win98"
  32. #endif
  33.  
  34. #if defined(_WIN64) || defined(WIN64)
  35. #define MACHINE_TYPE    "ia64"        /* Define to machine type name */
  36. #else
  37. #define MACHINE_TYPE    "i32"        /* Define to machine type name */
  38. #ifndef _WIN32
  39. #define _WIN32                /* Compatible with old source */
  40. #endif
  41. #ifndef __WIN32__
  42. #define __WIN32__
  43. #endif
  44. #endif /* _WIN64 */
  45. #ifndef __WIN__
  46. #define __WIN__                  /* To make it easier in VC++ */
  47. #endif
  48.  
  49. /* File and lock constants */
  50. #define O_SHARE        0x1000        /* Open file in sharing mode */
  51. #ifdef __BORLANDC__
  52. #define F_RDLCK        LK_NBLCK    /* read lock */
  53. #define F_WRLCK        LK_NBRLCK    /* write lock */
  54. #define F_UNLCK        LK_UNLCK    /* remove lock(s) */
  55. #else
  56. #define F_RDLCK        _LK_NBLCK    /* read lock */
  57. #define F_WRLCK        _LK_NBRLCK    /* write lock */
  58. #define F_UNLCK        _LK_UNLCK    /* remove lock(s) */
  59. #endif
  60.  
  61. #define F_EXCLUSIVE    1        /* We have only exclusive locking */
  62. #define F_TO_EOF    (INT_MAX32/2)    /* size for lock of all file */
  63. #define F_OK        0        /* parameter to access() */
  64.  
  65. #define S_IROTH        S_IREAD        /* for my_lib */
  66.  
  67. #ifdef __BORLANDC__
  68. #define FILE_BINARY    O_BINARY    /* my_fopen in binary mode */
  69. #define O_TEMPORARY    0
  70. #define O_SHORT_LIVED    0
  71. #define SH_DENYNO    _SH_DENYNO
  72. #else
  73. #define O_BINARY    _O_BINARY    /* compability with MSDOS */
  74. #define FILE_BINARY    _O_BINARY    /* my_fopen in binary mode */
  75. #define O_TEMPORARY    _O_TEMPORARY
  76. #define O_SHORT_LIVED    _O_SHORT_LIVED
  77. #define SH_DENYNO    _SH_DENYNO
  78. #endif
  79. #define NO_OPEN_3            /* For my_create() */
  80.  
  81. #define SIGQUIT        SIGTERM        /* No SIGQUIT */
  82.  
  83. #undef _REENTRANT            /* Crashes something for win32 */
  84. #undef SAFE_MUTEX            /* Can't be used on windows */
  85.  
  86. #define LONGLONG_MIN    ((__int64) 0x8000000000000000)
  87. #define LONGLONG_MAX    ((__int64) 0x7FFFFFFFFFFFFFFF)
  88. #define ULONGLONG_MAX    ((unsigned __int64) 0xFFFFFFFFFFFFFFFF)
  89. #define LL(A)        ((__int64) A)
  90.  
  91. /* Type information */
  92.  
  93. typedef unsigned short    ushort;
  94. typedef unsigned int    uint;
  95. typedef unsigned __int64 ulonglong;    /* Microsofts 64 bit types */
  96. typedef __int64 longlong;
  97. typedef int sigset_t;
  98. #define longlong_defined
  99. /* off_t should not be __int64 because of conflicts in header files;
  100.    Use my_off_t or os_off_t instead */
  101. typedef long off_t;
  102. typedef __int64 os_off_t;
  103. #ifdef _WIN64
  104. typedef UINT_PTR rf_SetTimer;
  105. #else
  106. typedef unsigned int size_t;
  107. typedef uint rf_SetTimer;
  108. #endif
  109.  
  110. #define Socket_defined
  111. #define my_socket SOCKET
  112. #define bool BOOL
  113. #define SIGPIPE SIGINT
  114. #define RETQSORTTYPE void
  115. #define QSORT_TYPE_IS_VOID
  116. #define RETSIGTYPE void
  117. #define SOCKET_SIZE_TYPE int
  118. #define my_socket_defined
  119. #define bool_defined
  120. #define byte_defined
  121. #define HUGE_PTR
  122. #define STDCALL __stdcall        /* Used by libmysql.dll */
  123. #define isnan(X) _isnan(X)
  124. #define finite(X) _finite(X)
  125.  
  126. #ifndef UNDEF_THREAD_HACK
  127. #define THREAD
  128. #endif
  129. #define VOID_SIGHANDLER
  130. #define SIZEOF_CHAR        1
  131. #define SIZEOF_LONG        4
  132. #define SIZEOF_LONG_LONG    8
  133. #define SIZEOF_OFF_T        8
  134. #ifdef _WIN64
  135. #define SIZEOF_CHARP        8
  136. #else
  137. #define SIZEOF_CHARP        4
  138. #endif
  139. #define HAVE_BROKEN_NETINET_INCLUDES
  140. #ifdef __NT__
  141. #define HAVE_NAMED_PIPE            /* We can only create pipes on NT */
  142. #endif
  143.  
  144. /* We need to close files to break connections on shutdown */
  145. #ifndef SIGNAL_WITH_VIO_CLOSE
  146. #define SIGNAL_WITH_VIO_CLOSE
  147. #endif
  148.  
  149. /* Use all character sets in MySQL */
  150. #define USE_MB 1
  151. #define USE_MB_IDENT 1
  152. #define USE_STRCOLL 1
  153.  
  154. /* All windows servers should support .sym files */
  155. #undef USE_SYMDIR
  156. #define USE_SYMDIR
  157.  
  158. /* If LOAD DATA LOCAL INFILE should be enabled by default */
  159. #define ENABLED_LOCAL_INFILE 1
  160.  
  161. /* Convert some simple functions to Posix */
  162.  
  163. #define sigset(A,B) signal((A),(B))
  164. #define finite(A) _finite(A)
  165. #define sleep(A)  Sleep((A)*1000)
  166.  
  167. #ifndef __BORLANDC__
  168. #define access(A,B) _access(A,B)
  169. #endif
  170.  
  171. #if defined(__cplusplus)
  172.  
  173. inline double rint(double nr)
  174. {
  175.   double f = floor(nr);
  176.   double c = ceil(nr);
  177.   return (((c-nr) >= (nr-f)) ? f :c);
  178. }
  179.  
  180. #ifdef _WIN64
  181. #define ulonglong2double(A) ((double) (ulonglong) (A))
  182. #define my_off_t2double(A)  ((double) (my_off_t) (A))
  183.  
  184. #else
  185. inline double ulonglong2double(ulonglong value)
  186. {
  187.   longlong nr=(longlong) value;
  188.   if (nr >= 0)
  189.     return (double) nr;
  190.   return (18446744073709551616.0 + (double) nr);
  191. }
  192. #define my_off_t2double(A) ulonglong2double(A)
  193. #endif /* _WIN64 */
  194. #else
  195. #define inline __inline
  196. #endif /* __cplusplus */
  197.  
  198. #if SIZEOF_OFF_T > 4
  199. #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
  200. #define tell(A) _telli64(A)
  201. #endif
  202.  
  203. #define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
  204.  
  205. #define STACK_DIRECTION -1
  206.  
  207. /* Optimized store functions for Intel x86 */
  208.  
  209. #ifndef _WIN64
  210. #define sint2korr(A)    (*((int16 *) (A)))
  211. #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
  212.                   (((uint32) 255L << 24) | \
  213.                    (((uint32) (uchar) (A)[2]) << 16) |\
  214.                    (((uint32) (uchar) (A)[1]) << 8) | \
  215.                    ((uint32) (uchar) (A)[0])) : \
  216.                   (((uint32) (uchar) (A)[2]) << 16) |\
  217.                   (((uint32) (uchar) (A)[1]) << 8) | \
  218.                   ((uint32) (uchar) (A)[0])))
  219. #define sint4korr(A)    (*((long *) (A)))
  220. #define uint2korr(A)    (*((uint16 *) (A)))
  221. /*
  222.    ATTENTION !
  223.    
  224.     Please, note, uint3korr reads 4 bytes (not 3) !
  225.     It means, that you have to provide enough allocated space !
  226. */
  227. #define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
  228. #define uint4korr(A)    (*((unsigned long *) (A)))
  229. #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  230.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  231.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  232.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  233.                     (((ulonglong) ((uchar) (A)[4])) << 32))
  234. #define uint8korr(A)    (*((ulonglong *) (A)))
  235. #define sint8korr(A)    (*((longlong *) (A)))
  236. #define int2store(T,A)    *((uint16*) (T))= (uint16) (A)
  237. #define int3store(T,A)        { *(T)=  (uchar) ((A));\
  238.                   *(T+1)=(uchar) (((uint) (A) >> 8));\
  239.                   *(T+2)=(uchar) (((A) >> 16)); }
  240. #define int4store(T,A)    *((long *) (T))= (long) (A)
  241. #define int5store(T,A)    { *(T)= (uchar)((A));\
  242.               *((T)+1)=(uchar) (((A) >> 8));\
  243.               *((T)+2)=(uchar) (((A) >> 16));\
  244.               *((T)+3)=(uchar) (((A) >> 24)); \
  245.               *((T)+4)=(uchar) (((A) >> 32)); }
  246. #define int8store(T,A)    *((ulonglong *) (T))= (ulonglong) (A)
  247.  
  248. #define doubleget(V,M)    { *((long *) &V) = *((long*) M); \
  249.               *(((long *) &V)+1) = *(((long*) M)+1); }
  250. #define doublestore(T,V) { *((long *) T) = *((long*) &V); \
  251.                *(((long *) T)+1) = *(((long*) &V)+1); }
  252. #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
  253. #define float8get(V,M) doubleget((V),(M))
  254. #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
  255. #define float8store(V,M) doublestore((V),(M))
  256. #endif /* _WIN64 */
  257.  
  258. #define HAVE_PERROR
  259. #define HAVE_VFPRINT
  260. #define HAVE_RENAME        /* Have rename() as function */
  261. #define HAVE_BINARY_STREAMS    /* Have "b" flag in streams */
  262. #define HAVE_LONG_JMP        /* Have long jump function */
  263. #define HAVE_LOCKING        /* have locking() call */
  264. #define HAVE_ERRNO_AS_DEFINE    /* errno is a define */
  265. #define HAVE_STDLIB        /* everything is include in this file */
  266. #define HAVE_MEMCPY
  267. #define HAVE_MEMMOVE
  268. #define HAVE_GETCWD
  269. #define HAVE_TELL
  270. #define HAVE_TZNAME
  271. #define HAVE_PUTENV
  272. #define HAVE_SELECT
  273. #define HAVE_SETLOCALE
  274. #define HAVE_SOCKET        /* Giangi */
  275. #define HAVE_FLOAT_H
  276. #define HAVE_LIMITS_H
  277. #define HAVE_STDDEF_H
  278. #define HAVE_RINT        /* defined in this file */
  279. #define NO_FCNTL_NONBLOCK    /* No FCNTL */
  280. #define HAVE_ALLOCA
  281. #define HAVE_STRPBRK
  282. #define HAVE_STRSTR
  283. #define HAVE_COMPRESS
  284. #define HAVE_CREATESEMAPHORE
  285. #define HAVE_ISNAN
  286. #define HAVE_FINITE
  287. #define HAVE_ISAM        /* We want to have support for ISAM in 4.0 */
  288. #define HAVE_QUERY_CACHE
  289. #define SPRINTF_RETURNS_INT
  290. #define HAVE_SETFILEPOINTER
  291.  
  292. #ifdef NOT_USED
  293. #define HAVE_SNPRINTF        /* Gave link error */
  294. #define _snprintf snprintf
  295. #endif
  296.  
  297. #ifdef _MSC_VER
  298. #define HAVE_LDIV        /* The optimizer breaks in zortech for ldiv */
  299. #define HAVE_ANSI_INCLUDE
  300. #define HAVE_SYS_UTIME_H
  301. #define HAVE_STRTOUL
  302. #endif
  303. #define my_reinterpret_cast(A) reinterpret_cast <A>
  304. #define my_const_cast(A) const_cast<A>
  305.  
  306.  
  307. /* MYSQL OPTIONS */
  308.  
  309. #ifdef _CUSTOMCONFIG_
  310. #include <custom_conf.h>
  311. #else
  312. #define DEFAULT_MYSQL_HOME    "c:\\mysql"
  313. #define PACKAGE            "mysql"
  314. #define DEFAULT_BASEDIR        "C:\\"
  315. #define SHAREDIR        "share"
  316. #define DEFAULT_CHARSET_HOME    "C:/mysql/"
  317. #endif
  318.  
  319. /* File name handling */
  320.  
  321. #define FN_LIBCHAR    '\\'
  322. #define FN_ROOTDIR    "\\"
  323. #define FN_NETWORK_DRIVES    /* Uses \\ to indicate network drives */
  324. #define FN_NO_CASE_SENCE    /* Files are not case-sensitive */
  325. #define MY_NFILE    2048
  326.  
  327. #define DO_NOT_REMOVE_THREAD_WRAPPERS
  328. #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
  329. /* The following is only used for statistics, so it should be good enough */
  330. #ifdef __NT__  /* This should also work on Win98 but .. */
  331. #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
  332. #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
  333. #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
  334. #else
  335. #define thread_safe_add(V,C,L) \
  336.     pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
  337. #define thread_safe_sub(V,C,L) \
  338.     pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
  339. #define statistic_add(V,C,L)     (V)+=(C)
  340. #endif
  341. #define statistic_increment(V,L) thread_safe_increment((V),(L))
  342.